  var id = getvl("id");
 var shopids="";
$(function(){
	
	  if(id!=''){
	  	dianpuxinxi(id);
	  	zhanghuxinxi(id);
	  	$("#duihuanjilu").attr("href","23.3.0wodejinbi_duihuan.html?id="+id);
	  }else{
	  //	alert("传入值有误");
	  }
	
});




 function  dianpuxinxi(id){
          	$("#jingbidikouzhuangtai").html("");
          	$("#dikouzuigaobili").html("");
          	$("#wenben").val("");
          		$("#anniu").val("");
          		 $("#shifouqiyong").val("");
   	$.ajax({
		url: urlcore + "/api/shopInfo/selectagno1?id="+id,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
				var da=data.data;
          if(da.openGold==1){
          	//alert("开启");
          	$("#jingbidikouzhuangtai").append("启用抵扣");
          	$("#anniu").val("关闭抵扣");
          	  $("#shifouqiyong").val(0);
          }else{
          	//alert("关闭");
          	$("#jingbidikouzhuangtai").append("未启用抵扣");
          		$("#anniu").val("开启抵扣");
          		  $("#shifouqiyong").val(1);
          }
         $("#dikouzuigaobili").html(da.allGoldRate+"%");
          $("#wenben").val(da.allGoldRate);
           shopids=da.id;
        
         $("#shezhidanping").attr("href","23.4.0wodejinbi_danpin.html?shopid="+da.id);
			}
		},
		error:function() {
			/* Act on the event */
			alert("error");
		}
	});	
}






 function  zhanghuxinxi(id){
   	$.ajax({
		url: urlcore + "/api/goldRecord/selectGoldMsg2?id="+id,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
              $("#keyongjingbi").html("&yen;"+data.data.userGold);
			}
		},
		error:function() {
			/* Act on the event */
			alert("error");
		}
	});	
}

var currentPage1=1;
var ss=0;
function mingxi(){
	$("#fenye").val("1");
	if(id!=''){
		  if(currentPage1==1 || currentPage1==2 || ss!=0){
			$.ajax({
		url: urlcore + "/api/goldRecord/selectList3?current="+currentPage1+"&id="+id,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
				ss=data.data.list.length;
				$.each(data.data.list, function(y,n) {
					//	var gmtDatetime = new Date().pattern("yyyy-MM-dd hh:mm:ss");
					var jingbijilu='<dd class="clearfix">'+
'				<div class="yue_list_left">'+
'					<h5>'+n.title+'</h5>'+
'					<span>'+n.gmtDatetime+'</span>'+
'				</div>'+
'				<div class="yue_list_right">+'+n.gold+'</div>'+
'			</dd>';
				
				$("#jingbijilu").append(jingbijilu);
				});
			}
		},
		error:function() {
			/* Act on the event */
			alert("error");
		}
	});	
	}
	}else{
		alert("没有值传入");
	}
	
}



function jianhao(ts) {
	//alert(ts);
	var t = $(ts).next();
	if(t.val() != '' && t.val() > 0) {
		t.val(parseInt(t.val()) - 1);
	
	} else {
		t.val(0);
	}
}

function jiahao(ts) {
	var t = $(ts).prev();
	if(parseInt(t.val()) < 20) {
		t.val(parseInt(t.val()) + 1);
	} else {
		t.val(20);
	}
}




function wenbenkuang(ts) {
	var shu = $(ts);
	var results = /^(10|[1-9])$/.test(shu.val()); //?"正":"非正";
	if(parseInt(shu.val()) > 20) {
		shu.val(20);
	} else if(parseInt(shu.val()) <= 3 || shu.val() == "") {
		shu.val(3);
	} else if(results == false) {
		shu.val(3);
	}
}


function queren(str){
	 // alert(shopids);
	     var kai=$("#shifouqiyong").val();
	  if(str==1){
	  			  $("#dikouzuigaobili").html("");
	  		  var jinb=$(".jinbi_show").find("#wenben").val();
	  $("#dikouzuigaobili").html($(".jinbi_show").find("#wenben").val()+"%");
	  	
         	  	 $.ajax({  
        url : urlcore + "/api/shopInfo/shopupdate",
        type : "post",  
        contentType: "application/json;charset=utf-8",
        data :  JSON.stringify({  //所在省市
        	  "id":shopids,
        	  "allGoldRate":jinb
        	}),
        	dataType: "json",
        success: function(data) {//data是返回的hash,key之类的值，key是定义的文件名 
        	//alert("修改成功!");
        	//window.location.href = document.referrer
        },
        error:function(){  
            alert("修改失败");  
        }  
    });     
	  	
	  }else if(str==2){
	  		$("#jingbidikouzhuangtai").html("");
         	  	 $.ajax({  
        url : urlcore + "/api/shopInfo/shopupdate",
        type : "post",  
        contentType: "application/json;charset=utf-8",
        data :  JSON.stringify({  //所在省市
        	  "id":shopids,
        	   "openGold":kai
        	}),
        	dataType: "json",
        success: function(data) {//data是返回的hash,key之类的值，key是定义的文件名 
        	var  da=data.data;
        	if(da.openGold==1){
          	//alert("开启");
          	$("#jingbidikouzhuangtai").append("启用抵扣");
          	$("#anniu").val("关闭抵扣");
          	  $("#shifouqiyong").val(0);
          }else{
          	//alert("关闭");
          	$("#jingbidikouzhuangtai").append("未启用抵扣");
          		$("#anniu").val("开启抵扣");
          		  $("#shifouqiyong").val(1);
          }
        },
        error:function(){  
            alert("修改失败");  
        }  
    });     
	  }
	   
}


